#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void *p1,const void *p2)
{
	return(*(int*)p1 - *(int*)p2);
}

void swap(void *p1,void *p2,int width)
{
	int i = 0;
	for (i = 0; i < width; i++)
	{
		char tmp = *((char*)p1 + i);
		*((char*)p1 + i) = *((char*)p2 + i);
		*((char*)p2 + i) = tmp;
	}
}

void bubble_sort(int *arr, int sz, int width, int(*cmp)(const void*, const void*))
{
	int i = 0;
	int j = 0;
	for (i = 0; i < sz - 1; i++)
	{
		for (j = 0; j < sz - 1 - i; j++)
		{
			if (cmp((char*)arr + j * width, (char*)arr + (j + 1) * width) > 0)
			{
				swap((char*)arr + j * width, (char*)arr + (j + 1) * width, );
			}
		}
	}
}

void test04()
{
	int arr[] = { 9,8,7,6,5,4,3,2,1,0 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	bubble_sort(arr, sz, sizeof(arr[0]), cmp);
	for (int i = 0; i < sz; i++)
	{
		printf("%d ", *(arr+i));
	}

}

int main()
{
	test04();

	return 0;
}